package com.zxx.order.presenter

import com.zqq.baselibrary.ext.excute
import com.zqq.baselibrary.http.rx.BaseSubscriber
import com.zqq.baselibrary.presenter.BasePresenter
import com.zxx.order.presenter.iview.OrderDetailView
import com.zxx.order.service.OrderService
import com.zxx.order.service.bean.Order
import javax.inject.Inject

/**
 * 订单详情页Presenter
 * wc
 * @author zqq on 2019/9/12.
 */
class OrderDetailPresenter @Inject constructor() : BasePresenter<OrderDetailView>() {

    @Inject
    lateinit var orderService: OrderService

    /*
        根据ID查询订单
     */
    fun getOrderById(orderId: Int) {
        if (!checkNetWork()) {
            return
        }
        mView.showLoading()
        orderService.getOrderById(orderId)
                .excute(object : BaseSubscriber<Order>(mView) {
                    override fun onNext(t: Order) {
                        mView.onGetOrderByIdResult(t)
                    }
                }, lifecycleProvider)

    }

}